package com.waypolice.manager.service.impl;

import com.waypolice.common.pojo.SearchResult;
import com.waypolice.common.utils.MathUtils;
import com.waypolice.manager.service.SolrAllTextSearchService;
import com.waypolice.manager.service.UpmsDictionaryService;
import com.waypolice.mapper.CmsBorRegFileMapper;
import com.waypolice.mapper.CmsBorRegisterMapper;
import com.waypolice.pojo.*;
import com.waypolice.pojo.handwriting.SolrFieldVO;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.MapSolrParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @ClassName SolrAllTextSearchServiceImpl
 * @Description TODO
 * @Author Administrator
 * @Date 2019/8/5 000508:36
 */
@Service
public class SolrAllTextSearchServiceImpl implements SolrAllTextSearchService {
    private static Logger logger = LoggerFactory.getLogger(SolrAllTextSearchServiceImpl.class);

    @Autowired(required = true)
    private SolrClient solrClient;

    @Autowired
    private UpmsDictionaryService upmsDictionaryService;

    @Autowired
    private CmsBorRegisterMapper cmsBorRegisterMapper;

    @Autowired
    private CmsBorRegFileMapper cmsBorRegFileMapper;

    /**
     * 新增或者更新文档
     */
    @Override
    public void saveSolr(List<SolrFieldVO> list){
        for (SolrFieldVO solrFieldVO : list) {
            SolrInputDocument solrInputFields = new SolrInputDocument();
            //为文档指定ID，即addField("id","文档id")，如果id相同则操作为更新。
            solrInputFields.addField("id",solrFieldVO.getId());
            solrInputFields.addField("typeTable",solrFieldVO.getTypeTable());
            solrInputFields.addField("arcId",solrFieldVO.getArcId());
            solrInputFields.addField("title",solrFieldVO.getTitle());
            solrInputFields.addField("itemOrVolNum",solrFieldVO.getItemOrVolNum());
            solrInputFields.addField("volNo",solrFieldVO.getVolNo());
            solrInputFields.addField("auditLeader",solrFieldVO.getAuditLeader());
            solrInputFields.addField("textNum",solrFieldVO.getTextNum());
            solrInputFields.addField("arcClass",solrFieldVO.getArcClass());
            solrInputFields.addField("storageTime",solrFieldVO.getStorageTime());
            solrInputFields.addField("archiveYear",solrFieldVO.getArchiveYear());
            solrInputFields.addField("archiveUnit",solrFieldVO.getArchiveUnit());
            solrInputFields.addField("secretLevel",solrFieldVO.getSecretLevel());
            solrInputFields.addField("volTotal",solrFieldVO.getVolTotal());
            solrInputFields.addField("archivePerson",solrFieldVO.getArchivePerson());
            solrInputFields.addField("postDate",solrFieldVO.getPostDate());
            solrInputFields.addField("itemStatus",solrFieldVO.getItemStatus());
            solrInputFields.addField("whetherPublic",solrFieldVO.getWhetherPublic());
            solrInputFields.addField("carrierType",solrFieldVO.getCarrierType());
            solrInputFields.addField("pdfUrl",solrFieldVO.getPdfUrl());
            solrInputFields.addField("pdfContent",solrFieldVO.getPdfContent());

            try {
                //提交
                UpdateResponse add = solrClient.add(solrInputFields);
                solrClient.commit();
            } catch (SolrServerException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            logger.info("***********保存成功**************");
        }

    }

    @Override
    public SolrDocumentList querySolr(String str) {
        //solr的查询语句：与使用AND，或使用OR。列如：title:地方部分OR archivePerson:地方部分
        String q="title:"+str+
                " OR auditLeader:"+str+
                " OR itemOrVolNum:"+str+
                " OR textNum:"+str+
                " OR archiveUnit:"+str+
                " OR archivePerson:"+str+
                " OR postDate:"+str+
                " OR pdfContent:"+str;

        //封装查询参数
        HashMap<String, String> selectParam = new HashMap<>();
        selectParam.put("q",q);
        selectParam.put("wt","json");

        // 添加到SolrParams对象,SolrParams 有一个 SolrQuery 子类，它提供了一些方法极大地简化了查询操作
        MapSolrParams entries = new MapSolrParams(selectParam);
        QueryResponse queryResponse = null;
        try {
            queryResponse = solrClient.query(entries);
        } catch (SolrServerException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        SolrDocumentList results = queryResponse.getResults();
        //查询结果总数
        long numFound = results.getNumFound();
        logger.info("总条数为" + numFound + "条");
        System.out.println("总条数为" + numFound + "条");
        return results;
    }

    @Override
    public void deleteSolr(){
        try {
            //根据条件删除
            solrClient.deleteByQuery("*:*");
            solrClient.commit();

        } catch (SolrServerException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("删除成功");
    }

    @Override
    public SearchResult findAllVolumeAndItemBySolr(String searchStr) {
        SearchResult newSearchResult = new SearchResult();
        List<CmsSinItem> newSinItemlist = new ArrayList<>();
        List<CmsJudItem> newItemlist = new ArrayList<>();
        List<CmsJudVolume> newVolList = new ArrayList<>();
        SolrDocumentList solrDocuments = querySolr(searchStr);
        for (SolrDocument solrDocument : solrDocuments) {
            String typeTable = solrDocument.get("typeTable").toString();
            if(StringUtils.isNotBlank(typeTable) && "vol".equals(typeTable)){
                //卷
                CmsJudVolume cmsJudVolume = addCmsJudVolume(solrDocument);
                newVolList.add(cmsJudVolume);
            }else if(StringUtils.isNotBlank(typeTable) && "volItem".equals(typeTable)){
                //卷内件
                CmsJudItem cmsJudItem = addCmsJudItem(solrDocument);
                newItemlist.add(cmsJudItem);
            }else if(StringUtils.isNotBlank(typeTable) && "sinItem".equals(typeTable)){
                //单件
                CmsSinItem cmsSinItem = addCmsSinItem(solrDocument);
                newSinItemlist.add(cmsSinItem);
            }
        }
        //solr检索的全为归档后的案卷和单件
        newSearchResult.setVollist(newVolList);
        newSearchResult.setItemlist(newItemlist);
        newSearchResult.setSinItemlist(newSinItemlist);
        newSearchResult.setSearchVolNum(newVolList.size());
        newSearchResult.setSearchItemNum(newItemlist.size());
        newSearchResult.setSearchSinItemNum(newSinItemlist.size());

        return newSearchResult;
    }

    @Override
    public SearchResult getUserVolumeAndItemBySolr(String searchStr) {
        //不是档案管理员，判断检索范围
        List<UpmsDictionary> types = upmsDictionaryService.findAllSearchScope();
        SearchResult results=null;
        if(types.size()!=0){
            String scope = "";
            for (UpmsDictionary type : types) {
                if ("1".equals(type.getStr2())) {
                    if (type.getCode().equals("search-public")) {
                        scope = "1";
                    } else {
                        scope = "2";
                    }
                }
            }
            if ("".equals(scope)) {
                //全部检索
                results = findAllVolumeAndItemBySolr(searchStr);
            } else if ("1".equals(scope)) {
                //按公开检索
                results = getPublicVolumeAndItem(searchStr);
            } else {
                //按涉密检索
                results = getSecretVolumeAndItem(searchStr);
            }
        }
        return results;
    }

    @Override
    public SearchResult getPublicVolumeAndItem(String searchStr) {
        SearchResult newSearchResult = new SearchResult();
        List<CmsSinItem> newSinItemlist = new ArrayList<>();
        List<CmsJudItem> newItemlist = new ArrayList<>();
        List<CmsJudVolume> newVolList = new ArrayList<>();
        SolrDocumentList solrDocuments = querySolr(searchStr);
        for (SolrDocument solrDocument : solrDocuments) {
            String typeTable = solrDocument.get("typeTable").toString();
            Integer integer = solrDocument.get("whetherPublic") == null ? null : (Integer) solrDocument.get("whetherPublic");
            if(StringUtils.isNotBlank(typeTable) && "vol".equals(typeTable)) {
                if (1 == integer.intValue()) {
                    //卷公开
                    CmsJudVolume cmsJudVolume = addCmsJudVolume(solrDocument);
                    newVolList.add(cmsJudVolume);
                } else {
                    //卷非公开
                    List<CmsJudVolume> secretOrNoPublic = getSecretOrNoPublic(solrDocument);
                    newVolList.addAll(secretOrNoPublic);
                }
            }else if(StringUtils.isNotBlank(typeTable) && "volItem".equals(typeTable)){
                if (1 == integer.intValue()) {
                    //卷内件公开
                    CmsJudItem cmsJudItem = addCmsJudItem(solrDocument);
                    newItemlist.add(cmsJudItem);
                }else {
                    //卷内件非公开
                    List<CmsJudItem> volInnerItemSecretOrNoPublic = getVolInnerItemSecretOrNoPublic(solrDocument);
                    newItemlist.addAll(volInnerItemSecretOrNoPublic);
                }
            }else if(StringUtils.isNotBlank(typeTable) && "sinItem".equals(typeTable)){
                if (1 == integer.intValue()) {
                    //单件公开
                    CmsSinItem cmsSinItem = addCmsSinItem(solrDocument);
                    newSinItemlist.add(cmsSinItem);
                }else {
                    //单件不公开
                    List<CmsSinItem> sinItemSecretOrNoPublic = getSinItemSecretOrNoPublic(solrDocument);
                    newSinItemlist.addAll(sinItemSecretOrNoPublic);
                }
            }
        }
        //solr检索的全为归档后的案卷和单件
        newSearchResult.setVollist(newVolList);
        newSearchResult.setItemlist(newItemlist);
        newSearchResult.setSinItemlist(newSinItemlist);
        newSearchResult.setSearchVolNum(newVolList.size());
        newSearchResult.setSearchItemNum(newItemlist.size());
        newSearchResult.setSearchSinItemNum(newSinItemlist.size());
        return newSearchResult;
    }

    @Override
    public SearchResult getSecretVolumeAndItem(String searchStr) {
        SearchResult newSearchResult = new SearchResult();
        List<CmsSinItem> newSinItemlist = new ArrayList<>();
        List<CmsJudItem> newItemlist = new ArrayList<>();
        List<CmsJudVolume> newVolList = new ArrayList<>();
        SolrDocumentList solrDocuments = querySolr(searchStr);
        for (SolrDocument solrDocument : solrDocuments) {
            String typeTable = solrDocument.get("typeTable").toString();
            String secretLevel = solrDocument.get("secretLevel") == null ? null : solrDocument.get("secretLevel").toString();
            if(StringUtils.isNotBlank(typeTable) && "vol".equals(typeTable)){
                if(StringUtils.isBlank(secretLevel)){
                    //卷不涉密
                    CmsJudVolume cmsJudVolume = addCmsJudVolume(solrDocument);
                    newVolList.add(cmsJudVolume);
                }else {
                    //卷涉密
                    List<CmsJudVolume> secretOrNoPublic = getSecretOrNoPublic(solrDocument);
                    newVolList.addAll(secretOrNoPublic);
                }
            }else if(StringUtils.isNotBlank(typeTable) && "volItem".equals(typeTable)){
                if(StringUtils.isBlank(secretLevel)){
                    //卷内件不涉密
                    CmsJudItem cmsJudItem = addCmsJudItem(solrDocument);
                    newItemlist.add(cmsJudItem);
                }else {
                    //卷内件涉密
                    List<CmsJudItem> volInnerItemSecretOrNoPublic = getVolInnerItemSecretOrNoPublic(solrDocument);
                    newItemlist.addAll(volInnerItemSecretOrNoPublic);
                }
            }else if(StringUtils.isNotBlank(typeTable) && "sinItem".equals(typeTable)){
                if(StringUtils.isBlank(secretLevel)){
                    //单件不涉密
                    CmsSinItem cmsSinItem = addCmsSinItem(solrDocument);
                    newSinItemlist.add(cmsSinItem);
                }else {
                    //单件涉密
                    List<CmsSinItem> sinItemSecretOrNoPublic = getSinItemSecretOrNoPublic(solrDocument);
                    newSinItemlist.addAll(sinItemSecretOrNoPublic);
                }
            }
        }

        //solr检索的全为归档后的案卷和单件
        newSearchResult.setVollist(newVolList);
        newSearchResult.setItemlist(newItemlist);
        newSearchResult.setSinItemlist(newSinItemlist);
        newSearchResult.setSearchVolNum(newVolList.size());
        newSearchResult.setSearchItemNum(newItemlist.size());
        newSearchResult.setSearchSinItemNum(newSinItemlist.size());

        return newSearchResult;
    }

    private List<CmsSinItem> getSinItemSecretOrNoPublic(SolrDocument solrDocument) {
        List<CmsSinItem> cmsSinItems = new ArrayList<>();
        //单件非公开
        List<CmsBorRegister> userIsNoPunlic = getUserIsNoPunlic();
        for (CmsBorRegister cmsBorRegister : userIsNoPunlic) {
            Long id = cmsBorRegister.getId();
            CmsBorRegFileExample cmsBorRegFileExample = new CmsBorRegFileExample();
            CmsBorRegFileExample.Criteria criteria2 = cmsBorRegFileExample.createCriteria();
            criteria2.andBorRegIdEqualTo(id);
            criteria2.andFileShapeEqualTo("1");
            List<CmsBorRegFile> cmsBorRegFiles = cmsBorRegFileMapper.selectByExample(cmsBorRegFileExample);
            for (CmsBorRegFile cmsBorRegFile : cmsBorRegFiles) {
                //第三步：将未公开的内卷与用户所拥有权限的卷内件id作比较，如果相同，将未公开的卷放入finalList
                Long fileId = cmsBorRegFile.getFileId();
                if (fileId.equals((Long) solrDocument.get("arcId"))) {
                    //卷内件公开
                    CmsSinItem cmsSinItem = addCmsSinItem(solrDocument);
                    cmsSinItems.add(cmsSinItem);
                }
            }
        }
        return cmsSinItems;
    }

    private List<CmsJudItem> getVolInnerItemSecretOrNoPublic(SolrDocument solrDocument) {
        List<CmsJudItem> cmsJudItems = new ArrayList<>();
        List<CmsBorRegister> userIsNoPunlic = getUserIsNoPunlic();
        for (CmsBorRegister cmsBorRegister : userIsNoPunlic) {
            Long id = cmsBorRegister.getId();
            CmsBorRegFileExample cmsBorRegFileExample = new CmsBorRegFileExample();
            CmsBorRegFileExample.Criteria criteria2 = cmsBorRegFileExample.createCriteria();
            criteria2.andBorRegIdEqualTo(id);
            criteria2.andFileShapeEqualTo("1");
            List<CmsBorRegFile> cmsBorRegFiles = cmsBorRegFileMapper.selectByExample(cmsBorRegFileExample);
            for (CmsBorRegFile cmsBorRegFile : cmsBorRegFiles) {
                //第三步：将未公开的内卷与用户所拥有权限的卷内件id作比较，如果相同，将未公开的卷放入finalList
                Long fileId = cmsBorRegFile.getFileId();
                if (fileId.equals((Long) solrDocument.get("arcId"))) {
                    //卷内件公开
                    CmsJudItem cmsJudItem = addCmsJudItem(solrDocument);
                    cmsJudItems.add(cmsJudItem);
                }
            }
        }

        return cmsJudItems;
    }

    private List<CmsBorRegister> getUserIsNoPunlic() {
        //1：先查询该用户有效的申请检索记录
        //剩下未公开的，查询当前登录用户是否有资格查看，如果有，放入finalList
        Subject subject = SecurityUtils.getSubject();
        UpmsUser user = (UpmsUser) subject.getSession().getAttribute("loginUser");
        Integer userId = user.getUserId();
        CmsBorRegisterExample cmsBorRegisterExample = new CmsBorRegisterExample();
        CmsBorRegisterExample.Criteria criteria1 = cmsBorRegisterExample.createCriteria();
        criteria1.andBorUserIdEqualTo(Long.valueOf(userId));
        criteria1.andBorStatusEqualTo(1);
        criteria1.andTaskTypeEqualTo(3);
        List<CmsBorRegister> cmsBorRegisters = cmsBorRegisterMapper.selectByExample(cmsBorRegisterExample);
        return cmsBorRegisters;
    }

    private CmsSinItem addCmsSinItem(SolrDocument solrDocument){
        CmsSinItem cmsSinItem = new CmsSinItem();
        cmsSinItem.setItemId(Long.valueOf(solrDocument.get("arcId").toString()));
        cmsSinItem.setItemName(solrDocument.get("textNum")==null?null:solrDocument.get("textNum").toString());
        cmsSinItem.setItemSecret(solrDocument.get("secretLevel")==null?null:solrDocument.get("secretLevel").toString());
        cmsSinItem.setItemTitle(solrDocument.get("title") == null ? null : solrDocument.get("title").toString());
        cmsSinItem.setItemRespons(solrDocument.get("archivePerson")==null?null:solrDocument.get("archivePerson").toString());
        cmsSinItem.setItemCreateTime(solrDocument.get("postDate")==null?null:solrDocument.get("postDate").toString());
        cmsSinItem.setItemStatus(solrDocument.get("itemStatus")==null?null: Long.valueOf(solrDocument.get("itemStatus").toString()));
        cmsSinItem.setItemStr1(solrDocument.get("itemOrVolNum") == null ? null : solrDocument.get("itemOrVolNum").toString());
        cmsSinItem.setItemStr2(solrDocument.get("pdfUrl")==null?null:solrDocument.get("pdfUrl").toString());
        cmsSinItem.setPdfContent(solrDocument.get("pdfContent")==null?null:solrDocument.get("pdfContent").toString());
        cmsSinItem.setItemExp1(solrDocument.get("arcClass")==null?null:solrDocument.get("arcClass").toString());
        cmsSinItem.setItemExp2(solrDocument.get("archiveUnit")==null?null:solrDocument.get("archiveUnit").toString());
        cmsSinItem.setItemExp3(solrDocument.get("archiveYear")==null?null:solrDocument.get("archiveYear").toString());
        cmsSinItem.setItemCarrier(solrDocument.get("carrierType")==null?null:solrDocument.get("carrierType").toString());
        cmsSinItem.setItemPublicStatus(solrDocument.get("whetherPublic")==null?null: Integer.valueOf(solrDocument.get("whetherPublic").toString()));
        cmsSinItem.setItemStr2(solrDocument.get("pdfUrl")==null?null:solrDocument.get("pdfUrl").toString());
        //抽取PDF文字阶段，因使用的插件产生Evaluation Warning : The document was created with Spire.PDF for Java水印
        //在存入solr阶段无法去掉，只有在查询出来阶段进行去除
        String s = solrDocument.get("pdfContent") == null ? null : solrDocument.get("pdfContent").toString().trim();
        String s2 = MathUtils.replaceBlank("Evaluation Warning : The document was created with Spire.PDF for Java").trim();
        logger.info("查询solr对PDF中的水印切除后文段********:"+s2);

        String s1 = s.replaceAll(s2, "");
        cmsSinItem.setPdfContent(s1);
        return cmsSinItem;
    }

    private CmsJudItem addCmsJudItem(SolrDocument solrDocument){
        CmsJudItem cmsJudItem = new CmsJudItem();
        cmsJudItem.setItemId(Long.valueOf(solrDocument.get("arcId").toString()));
        cmsJudItem.setItemName(solrDocument.get("textNum")==null?null:solrDocument.get("textNum").toString());
        cmsJudItem.setItemSecret(solrDocument.get("secretLevel")==null?null:solrDocument.get("secretLevel").toString());
        cmsJudItem.setItemTitle(solrDocument.get("title") == null ? null : solrDocument.get("title").toString());
        cmsJudItem.setItemRespons(solrDocument.get("archivePerson")==null?null:solrDocument.get("archivePerson").toString());
        cmsJudItem.setItemCreateTime(solrDocument.get("postDate")==null?null:solrDocument.get("postDate").toString());
        cmsJudItem.setItemStatus(solrDocument.get("itemStatus")==null?null: Long.valueOf(solrDocument.get("itemStatus").toString()));
        cmsJudItem.setItemStr1(solrDocument.get("itemOrVolNum") == null ? null : solrDocument.get("itemOrVolNum").toString());
        cmsJudItem.setItemStr2(solrDocument.get("pdfUrl")==null?null:solrDocument.get("pdfUrl").toString());
        cmsJudItem.setItemStr5(solrDocument.get("whetherPublic")==null?null: solrDocument.get("whetherPublic").toString());

        //抽取PDF文字阶段，因使用的插件产生Evaluation Warning : The document was created with Spire.PDF for Java水印
        //在存入solr阶段无法去掉，只有在查询出来阶段进行去除
        String s = solrDocument.get("pdfContent") == null ? null : solrDocument.get("pdfContent").toString().trim();
        String s2 = MathUtils.replaceBlank("Evaluation Warning : The document was created with Spire.PDF for Java").trim();
        logger.info("查询solr对PDF中的水印切除后文段********:"+s2);

        String s1 = s.replaceAll(s2, "");
        cmsJudItem.setPdfContent(s1);
        return cmsJudItem;
    }

    private CmsJudVolume addCmsJudVolume(SolrDocument solrDocument){
        CmsJudVolume cmsJudVolume = new CmsJudVolume();
        cmsJudVolume.setVolId(Long.valueOf(solrDocument.get("arcId").toString()));
        cmsJudVolume.setVolTitle(solrDocument.get("title") == null ? null : solrDocument.get("title").toString());
        cmsJudVolume.setVolCaseNum(solrDocument.get("itemOrVolNum") == null ? null : solrDocument.get("itemOrVolNum").toString());
        cmsJudVolume.setVolNo(solrDocument.get("volNo") == null ? null : solrDocument.get("volNo").toString());
        cmsJudVolume.setVolAuditLeader(solrDocument.get("auditLeader") == null ? null : solrDocument.get("auditLeader").toString());
        cmsJudVolume.setVolClass(solrDocument.get("arcClass") == null ? null : solrDocument.get("arcClass").toString());
        cmsJudVolume.setVolStoragelocation(solrDocument.get("storageTime") == null ? null : solrDocument.get("storageTime").toString());
        cmsJudVolume.setVolArchiveYear(solrDocument.get("archiveYear") == null ? null : solrDocument.get("archiveYear").toString());
        cmsJudVolume.setVolArchiveUnit(solrDocument.get("archiveUnit") == null ? null : solrDocument.get("archiveUnit").toString());
        cmsJudVolume.setVolSecret(solrDocument.get("secretLevel") == null ? null : solrDocument.get("secretLevel").toString());
        cmsJudVolume.setVolTotal(solrDocument.get("volTotal") == null ? null : solrDocument.get("volTotal").toString());
        cmsJudVolume.setVolArchivePerson(solrDocument.get("archivePerson") == null ? null : solrDocument.get("archivePerson").toString());
        cmsJudVolume.setVolPublicStatus(solrDocument.get("whetherPublic") == null ? null : Integer.valueOf(solrDocument.get("whetherPublic").toString()));
        cmsJudVolume.setVolCarrier(solrDocument.get("carrierType") == null ? null : solrDocument.get("carrierType").toString());

        return cmsJudVolume;
    }

    private List<CmsJudVolume> getSecretOrNoPublic(SolrDocument solrDocument) {
        List<CmsJudVolume> cmsJudVolumes = new ArrayList<>();
        List<CmsBorRegister> userIsNoPunlic = getUserIsNoPunlic();
        for (CmsBorRegister cmsBorRegister : userIsNoPunlic) {
            Long id = cmsBorRegister.getId();
            CmsBorRegFileExample cmsBorRegFileExample = new CmsBorRegFileExample();
            CmsBorRegFileExample.Criteria criteria2 = cmsBorRegFileExample.createCriteria();
            criteria2.andBorRegIdEqualTo(id);
            criteria2.andFileShapeEqualTo("0");
            List<CmsBorRegFile> cmsBorRegFiles = cmsBorRegFileMapper.selectByExample(cmsBorRegFileExample);
            for (CmsBorRegFile cmsBorRegFile : cmsBorRegFiles) {
                //第三步：将未公开的卷与用户所拥有权限的卷id作比较，如果相同，将未公开的卷放入finalList
                Long fileId = cmsBorRegFile.getFileId();
                if (fileId.equals((Long) solrDocument.get("arcId"))) {
                    CmsJudVolume cmsJudVolume = addCmsJudVolume(solrDocument);
                    cmsJudVolumes.add(cmsJudVolume);
                }
            }
        }
        return cmsJudVolumes;
    }

}
